:- module(web_utils, [generate_box/2], []).

:- use_module(portalfiles(page_pieces), [amos_left_arrow/1]).
:- use_module(portalfiles(get_page_info), [
        box_def/2,
        resolve_link/2,
        link_info/3
                                              ]).
generate_box(BoxName, Pillow):-
        (
            box_def(BoxName, sb(BoxTitle, ComponentList)) ->
            true
        ;
            throw(box_name_not_found(BoxName))
        ),
        Pillow = [env(div, [], [BoxTitle])|RestBox],
        make_sidebox(ComponentList, RestBox).

make_sidebox([], [nl]).
make_sidebox([Id|Ids],
             [nl,
              env(a, [href=RealLink], 
                    [nl, Text])|RestBox]):-
%                     [nl, Arrow, nl, Text])|RestBox]):-
%        amos_left_arrow(Arrow),
        link_info(Id, Text, SymbolicLink),
        resolve_link(SymbolicLink, RealLink),
        make_sidebox(Ids, RestBox).
